function Hero(opts) {
  this.basicInfo = new HeroBasicInfo(opts.basicInfo)
  this.fightAttri = new HeroFightAttri(opts.fightAttri)
  this.calcHeroAttri = function(boss) {
    this.fightAttri = new HeroFightAttri({})
    var attriPercent = this.fightAttri.attriPercent
      //计算基础属性
    for (var j in lvlupConfig['heroLvl'].addAttri) { //英雄等级
      this.fightAttri[j] += (this.basicInfo['heroLvl'] - 1) * lvlupConfig['heroLvl'].addAttri[j]
    }
    var lvls = ['attackLvl', 'attackSpeedLvl', 'critRateLvl', 'critHurtLvl', 'punctureLvl']
    for (var i = 0; i < lvls.length; i++) {
      var lvlCon = lvls[i]
      var config = lvlupConfig[lvlCon]
      if (this.basicInfo[lvlCon] > 1) {
        for (var j in config.addAttri) {
          this.fightAttri[j] += (this.basicInfo[lvlCon] - 1) * config.addAttri[j]
          this.fightAttri[j] += config.basicValue
        }
      } else if (this.basicInfo[lvlCon] === 1) {
        for (var j in config.addAttri) {
          this.fightAttri[j] += config.basicValue
        }
      }
    }
    //计算被动技能
    for (var i in this.basicInfo.skills) {
      var skillLvl = this.basicInfo.skills[i].lvl
      if (skillLvl === 0) {
        continue
      }

      var skillId = parseInt(i)
      switch (skillId) {
        case 440002: //攻击增幅
          attriPercent.attackPer += skillConfig[440002].values[skillLvl - 1]
          break;
        case 440003: //迅捷
          attriPercent.skillCdPer += skillConfig[440003].values[skillLvl - 1]
          break;
        case 440004: //专注
          attriPercent.critHurtPer += skillConfig[440004].values[skillLvl - 1]
          break;
        case 440005: //残酷
          attriPercent.puncturePer += skillConfig[440005].values[skillLvl - 1]
          break;
        case 440006: //攻速增幅
          attriPercent.attackSpeedPer += skillConfig[440006].values[skillLvl - 1]
          break;
        case 440007: //麻痹
          attriPercent.controlDamagePer += skillConfig[440007].values[skillLvl - 1]
        case 440013: //魔王降临
          attriPercent.puncture += skillConfig[440013].values[skillLvl - 1]
        case 440017: //强击光环
          attriPercent.attack += skillConfig[440017].values[skillLvl - 1]
        default:
      }
    }
    //计算buff
    for (var i in this.basicInfo.buffs) {
      var buffId = parseInt(i)
      switch (buffId) {
        case 450012: //支配死灵
          attriPercent.attack += buffConfig[450012].value * this.basicInfo.buffs[i].stack
          break;
        case 450014: //'魂之挽歌buff'
          attriPercent.puncture += buffConfig[450014].values[this.basicInfo.thunderSkill.lvl - 1]
          break;
        case 450018: //'射手天赋buff'
          attriPercent.attackSpeedPer += buffConfig[450018].values[this.basicInfo.skills[440018].lvl - 1]
          break;
      }
    }
    //总
    this.fightAttri.attack += attriPercent.attack
    this.fightAttri.attack += Math.floor(this.fightAttri.attack * attriPercent.attackPer / 100)
    this.fightAttri.puncture += attriPercent.puncture
    this.fightAttri.puncture += Math.floor(this.fightAttri.puncture * attriPercent.puncturePer / 100)
    this.fightAttri.attackSpeed += attriPercent.attackSpeed
    this.fightAttri.attackSpeed += Math.floor(this.fightAttri.attackSpeed * attriPercent.attackSpeedPer / 100)
    this.fightAttri.critHurt += Math.floor(this.fightAttri.critHurt * attriPercent.critHurtPer / 100)

    //技能释放
    for (var i in this.basicInfo.skills) {
      releaseSkill(this, boss, i)
    }
  }
}

function Boss(opts) {
  this.fightAttri = new BossFightAttri(opts.fightAttri)
  this.basicInfo = new BossBasicInfo(opts.basicInfo)
  this.calcBossAttri = function() {}
}

function HeroBasicInfo(opts) {
  this.name = opts.name || ''
  this.heroLvl = opts.heroLvl || 1
  this.attackLvl = opts.attackLvl || 1
  this.attackSpeedLvl = opts.attackSpeedLvl || 1
  this.critRateLvl = opts.critRateLvl || 0
  this.critHurtLvl = opts.critHurtLvl || 0
  this.punctureLvl = opts.punctureLvl || 0
  this.alchemyLvl = opts.alchemyLvl || 0
  this.gold = opts.gold || 0
  this.totalGold = opts.totalGold || 0
  this.damageGold = opts.damageGold || 0
  this.skills = opts.skills || {}
  this.thunderSkillId = opts.thunderSkillId || {}
  this.thunderSkill = opts.thunderSkill || {}
  this.buffs = opts.buffs || {}
  this.anger = opts.anger || 0
}

function HeroFightAttri(opts) {
  this.attack = opts.attack || 0
  this.critRate = opts.critRate || 0
  this.critHurt = opts.critHurt || 0
  this.attackSpeed = opts.attackSpeed || 0
  this.skillHurtPer = opts.skillHurtPer || 0
  this.puncture = opts.puncture || 0
  this.attriPercent = opts.attriPercent || {
    attack: 0,
    attackPer: 0,
    attackSpeed: 0,
    attackSpeedPer: 0,
    puncture: 0,
    puncturePer: 0,
    skillCdPer: 0,
    controlDamagePer: 0,
    critHurtPer: 0,
  }
}

function BossFightAttri(opts) {
  this.maxHp = opts.maxHp || 10000
  this.hp = opts.hp || opts.maxHp
  this.defend = opts.defend || 0
  this.skillHurt = opts.skillHurt || 0
  this.dodge = opts.dodge || 0
}

function BossBasicInfo(opts) {
  this.lvl = opts.lvl || 0
  this.state = opts.state || 0 //1眩晕2虚弱3中毒
  this.buffs = opts.buffs || {}
  this.debuffs = opts.debuffs || {}
  var skills = bossConfig.skills
  if(lvl > 2){

  }
}
